import java.nio.charset.*;
import java.io.*;
import java.nio.file.*;
import java.util.*;

public class ReadFileToString {
    public static String readFile(String path, Charset encoding) throws IOException 
    {
        byte[] encoded = Files.readAllBytes(Paths.get(path));
        return new String(encoded, encoding);
    }

    public static void main(String[] args) throws IOException {
        String s = readFile("ReadFileToString.java",Charset.defaultCharset());

        System.out.println(s);

    }
}